package com.ynwt.domain;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.ynwt.enums.EventStatus;

import javax.persistence.*;
import java.util.Date;
import java.util.Set;

/**
 * Created by huangying on 2017/4/26.
 */
@Entity
@Table(indexes = {
        @Index(name = "pk_key", columnList = "c_key", unique = true)})
public class Event {

    @Id
    @Column(name = "c_key", length = 50)
    private String key;

    @Column(length = 50)
    private String name;

    @Column
    private String content;

    @Column
    private long ycoin;

    @Column
    @Enumerated(EnumType.STRING)
    private EventStatus status = EventStatus.ON;

    @Column
    @Temporal(TemporalType.TIMESTAMP)
    private Date startTime;

    @Column
    @Temporal(TemporalType.TIMESTAMP)
    private Date endTime;

    @OneToMany(cascade = CascadeType.ALL, mappedBy = "event", fetch = FetchType.LAZY)
    @JsonIgnore
    private Set<UserEvent> events;

//    @OneToMany(cascade = CascadeType.ALL, mappedBy = "event", fetch = FetchType.LAZY)
//    private Set<UserEventLock> locks;

    public Event() {
    }

    public Event(String key) {
        this.key = key;
    }

    public String getKey() {
        return key;
    }

    public void setKey(String key) {
        this.key = key;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }

    public long getYcoin() {
        return ycoin;
    }

    public void setYcoin(long ycoin) {
        this.ycoin = ycoin;
    }

    public Date getStartTime() {
        return startTime;
    }

    public void setStartTime(Date startTime) {
        this.startTime = startTime;
    }

    public Date getEndTime() {
        return endTime;
    }

    public void setEndTime(Date endTime) {
        this.endTime = endTime;
    }

    public Set<UserEvent> getEvents() {
        return events;
    }

    public void setEvents(Set<UserEvent> events) {
        this.events = events;
    }

    public EventStatus getStatus() {
        return status;
    }

    public void setStatus(EventStatus status) {
        this.status = status;
    }
}
